package textdiff {

	/**
	 * A Symbol is a unique line of text. Symbol state tells if the symbol occurs in
	 * OldOnly, NewOnly, UniqueMatch (Old & New exactly once each) or Other. Saves
	 * the last line number from each file.
	 */
	public class Symbol {
	    public static const UNINITIALIZED:int = -1;
	    public static const OLDONLY:int = 1;
	    public static const NEWONLY:int = 2;
	    public static const UNIQUEMATCH:int = 3;
	    public static const OTHER:int = 4;
	
	    /** mState is a bitmap */
	    private var _state:int = 0;
	    private var _lineNum:Array = new Array();
	
	    public function Symbol() {
	    }
	
	    /** Returns state after counting the line */
	    public function countLine(aFile:int, aLineNum:int): int {
	        _lineNum[aFile] = aLineNum;
	        return adjustState( aFile + 1 );
	    }
	
	    /** Adusts and returns state */
	    private function adjustState(newState:int): int {
	        if ((_state & newState) == newState)
	            _state = OTHER;
	        else
	            _state = Math.min( OTHER, _state | newState );
	        return _state;
	    }
	
	    public function get state(): int {
	        return _state;
	    }
	
	    public function getLineNum(fileIx:int): int {
	        return _lineNum[fileIx];
	    }

	    public function get lineNum(): Array {
	        return _lineNum;
	    }
	}
}